package graph;

//顶点不依赖边， 边依赖顶点
public class Edge<V> {
    //权重
    int weight;
    Node<V> from;//起点
    Node<V> to;//终点
    //边依赖顶点的条数。
    public Edge(int weight, Node<V> from, Node<V> to) {
        this.weight = weight;
        this.from = from;
        this.to = to;
    }

    public Edge(Node<V> from, Node<V> to, int weight) {
        this.weight = weight;
        this.from = from;
        this.to = to;
    }

    //----给包外提供的接口。
    //获取权重
    public int getWeight() {
        return weight;
    }
    //重新设置权重
    public void setWeight(int weight) {
        this.weight = weight;
    }
    //获取边的起点
    public Node<V> getFrom() {
        return from;
    }
    //设置边的起点
    public void setFrom(Node<V> from) {
        this.from = from;
    }
    //获取边的终点
    public Node<V> getTo() {
        return to;
    }
    //设置边的终点
    public void setTo(Node<V> to) {
        this.to = to;
    }

}
